﻿using GSOrganization.Application;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Furion.Web.Entry.Controllers;
[Authorize(AuthenticationSchemes = Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme)]
public class SysRoleController : BaseController
{

    private readonly ISysRoleService _sysrole;

    private readonly ISysMenuService _menu;
    public SysRoleController(ISysRoleService syslog,ISysMenuService menu)
    {
        _sysrole = syslog;
        _menu = menu;

    }
    [HttpGet]
    public IActionResult SystemTree(string id)
    {
        var data = _menu.SystemTree(id);

        return Json(data);

    }
    /// <summary>
    /// 角色-授权，保存角色的菜单
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    public IActionResult SetMenu([FromBody] SysRoleSyeMenuInput entity)
    {
        var data = _sysrole.SetMenu(entity);

        return Json(data);
       
    }
 
    /// <summary>
    /// 用户管理
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    public IActionResult Index()
    {

        return View();
    }
    /// <summary>
    /// 列表
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    public IActionResult DataSysRole([FromBody] SysRoleIndexInput param)
    {


        var data = _sysrole.DataSysRole(param);
        return Json(data);
    }
    /// <summary>
    /// 编辑
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    public IActionResult Edit(string id)
    {
         var data = _sysrole.GetSysRole(id);

        return View(data);
    }
    /// <summary>
    /// 编辑
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    public IActionResult EditSysRole([FromBody] SysRoleOutput entity)
    {
         
        var data = _sysrole.CreateSysRole(entity);

        return Json(data);
    }
    /// <summary>
    /// 删除
    /// </summary>
    /// <returns></returns>
    [HttpPost]
    public IActionResult DeleteSysRole(string id)
    {

        var data = _sysrole.DeleteRole(id);

        return Json(data);
    }
}